package com.tt.controller;

import com.tt.common.page.TtResult;
import com.tt.pojo.User;
import com.tt.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 用户相关
 * @author 青青
 */
@Controller
@RequestMapping("/user")
public class UserController
{
    private String prefix = "user";

    @Autowired
    private IUserService userService;

    /**
     * 个人中心页面
     * @return
     */
    @GetMapping("/profile")
    public String showIndex()
    {
        return  prefix + "/profile";
    }

    /**
     * 用户列表页面
     * @return
     */
    @GetMapping("/users")
    public String userPage()
    {
        return prefix + "/user";
    }


    /**
     * 获取用户列表
     * @param user
     * @return
     */
    @PostMapping("/userList")
    @ResponseBody
    public TtResult userList(User user)
    {
        TtResult result = userService.selectByUser(user);
        return result;
    }



}
